package org.ipmsg.core;

import java.net.InetAddress;

/**
 * 网络地址和端口
 * @author Vangie
 */
public class Address {

    private int port;
    private InetAddress inetAddress;

    public Address(int port, InetAddress inetAddress) {
        this.port = port;
        this.inetAddress = inetAddress;
    }

    public int getPort() {
        return port;
    }

    public InetAddress getInetAddress() {
        return inetAddress;
    }

    public String getStringAddress() {
        return inetAddress.getHostAddress();
    }

    @Override
    public String toString() {
        return (new StringBuilder("[")).append(getStringAddress()).append(":").append(port).append("]").toString();
    }
}
